<%@page import="com.djzhou.gmms.util.properties.PropUtil"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Jeasyframe v2.0 - Powered By Jeasyframe.org</title>
		<link href="main.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="<%=path %>/js/blackbox/js/jquery.blackbox.min.js"></script>
		<script type="text/javascript" src="<%=path %>/js/toastr/toastr.js"></script>
		<script type="text/javascript" src="<%=path %>/js/common.js"></script>
		<link rel="stylesheet" href="<%=path %>/js/blackbox/css/blackbox.css" type="text/css" />
		<link rel="stylesheet" href="<%=path %>/js/toastr/toastr.css" type="text/css" />
		<script type="text/javascript">
		//声明xbox对象
		var xbox=new BlackBox();
		$(function(){
			var url=window.location;
			var url2=window.top.location;
			if(url!=url2){
				window.top.location="<%=path%>/";
			}
			var erp_username=readCookie("erp_username");
			var erp_password=readCookie("erp_password");
			if(erp_username!="" && erp_password!=""){
				$("#username").val(erp_username);
				textClear(document.getElementById("username"));
				$("#password").val(erp_password);
				textClear(document.getElementById("password"));
			}
			//$("#username").focus();
			$("#username").keydown(function(event){
				if(event.keyCode==13){
					$("#password").focus();
				}
			});
			$("#password").keydown(function(event){
				if(event.keyCode==13){
					$("#login").triggerHandler("click");
				}
			});
			$("#login").click(function(){
				var username = $("#username").val();
				if (username == "") {
					$("#username").focus();
					j_tip("用户名不能为空！", 'error');
					return;
				}
				var password = $("#password").val();
				if (password == "") {
					$("#password").focus();
					j_tip("密码不能为空！", 'error');
					return;
				}
				$.ajax({
						url			:"<%=path%>/login/loginAjax_login_successFlagAction.action",
						type 		: "POST",
						dataType 	: "json",
						data		: {
							"username" : username,
							"password" : password
						},
						success 	: function(data) {
							if(data == 0){
								j_tip("用户名或密码不正确！", 'error');
							}else if(data == 2){
								j_tip("用户已经被禁用，请联系管理员！", 'error');
							}else if(data == 11){
								j_tip("系统维护中,请稍后登录！", 'error');
							} else {
								xbox.load("loading");
								if($("#savePwd").prop("checked")){
									writeCookie("erp_username",username,24*30);
									writeCookie("erp_password",password,24*30);
								}
								window.location="<%=path %>/default.action";
							}
						},
						error		:function(){
							xbox.alert("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
						}
				});
			});
		});
		
		function textClear(obj){
			$(obj).attr("style","");
		}
		function textFull(obj,image){
			if($(obj).val()==""){
				$(obj).attr("style","background-image: url(images/"+image+".png)");
			}else{
				$(obj).attr("style","");
			}
		}
		//通用TIP提示方法
		function j_tip(message,type){
			if(type== undefined || type==null){
				toastr.info(message);
			}else if(type=="error"){
				toastr.error(message);
			}else if(type=="success"){
				toastr.success(message);
			}else if(type=="warning"){
				toastr.warning(message);
			}else{
				toastr.info(message);
			}
		}
		
		</script>
	</head>
<body class="login_bg">
<div class="login_box">
	<div class="login_main">
	<table width="437" border="0" align="center" cellpadding="0" cellspacing="0">
	  <tr>
	    <td height="298" colspan="4" valign="bottom"><img src="images/logo.png" height="34" width="333" style="margin-bottom:10px;" /></td>
	    </tr>
	  <tr>
	    <td width="87" rowspan="3"><img src="images/login_pic.png" width="87" height="87" /></td>
	    <td width="10" rowspan="3">&nbsp;</td>
	    <td width="249" height="36" >
	      <input name="username" id="username" type="text" value="" class="login_txt1" onfocus="textClear(this)" onblur="textFull(this,'username')"  style="background-image: url(images/username.png)"/> 
	      </td>
	    <td width="92" rowspan="3" align="center" valign="middle"><span id="login" style="cursor: pointer;"><img src="images/buttom.png" width="66" height="66" /></span></td>
	  </tr>
	  <tr>
	    <td width="249" height="10"></td>
	  </tr>
	  <tr>
	    <td width="249" height="36"><span style="background-image:url(images/login_input.png); background-repeat:no-repeat;">
	      <input name="password" id="password" value="" type="password" onfocus="textClear(this)" onblur="textFull(this,'password')" style="background-image: url(images/password.png)" class="login_txt1" />
	    </span></td>
	  </tr>
	  <tr>
	    <td height="30" colspan="2">&nbsp;</td>
	    <td valign="bottom">
	    <table width="100%" border="0" cellspacing="0" cellpadding="0">
	      <tr>
	      		<td><input type="checkbox" value="1" id="savePwd" checked="checked" />记住密码</td>
	      		<td>技术支持:Jeasyframe.org</td>
	      </tr>
	    </table>
	    </td>
	    <td>&nbsp;</td>
	  </tr>
	</table>
</div>
</div>
</body>
</html>


